package com.jml.策略模式.comparable和comparator;

import java.util.Comparator;

/**
 * Comparator才是策略模式，Comparable不是策略模式
 */
public class Cat implements Comparator<Cat> {
    int weight, height;

    public Cat(int weight, int height) {
        this.weight = weight;
        this.height = height;
    }

    @Override
    public int compare(Cat c1, Cat c2) {
        if (c1.weight < c2.weight) {
            //表示当前对象更小
            return -1;
        } else if (c1.weight > c2.weight) {
            //表示当前对象更大
            return 1;
        } else {
            //一样大
            return 0;
        }
    }

}
